<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>商城导航</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
    <script src="../utils/flexible.js"></script>
    <link rel="stylesheet" href="../css/sitenav.css">
</head>
<body>
    <header>
        <button>返回</button>
        <p>商城导航</p>
        <img src="../images/header_app.png" alt="">
    </header>

    <!-- 内容 -->
    <ul class="center">

    </ul>

   


    <!-- 底部 -->
    <br>
    <footer>
        <ul>
            <li>登录</li>
            <li>注册</li>
            <li class="returntop">返回顶部</li>
        </ul>
        <p>
            手机APP下载慢慢买手机版-掌上比价平台<br>
            m.manmanbuy.com
        </p>
    </footer>

</body>
</html>

<script>
    // 返回上一级
    let bn=document.querySelector('button');
    bn.addEventListener('click',function(){
        history.go(-1);
    })
    
    // 数据函数
    function render1(data=[]){
        let html=""
        data.forEach(item=>{
            html+=`
                <li>
                    <a href="${item.navHref}">
                        <img src="${item.navImg}" alt="" srcset="">
                        <span>${item.navTitle}</span> 
                    </a>
                    
                </li>
            `
        })
        $("ul.center").html(html)
    }




    // ajax第一次获取数据
    $.ajax({
        url:'http://chst.vip:1234/api/getsitenav'
    })
    .then(res=>{
        console.log(res);
        render1(res.result)
    })
    

    
    // 返回顶部
    $('footer .returntop').click(function(e){
        document.documentElement.scrollTop=0;
    })

</script>